# -*- coding: utf-8 -*-

import logging
import json

from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from django.db.models.fields.related import RelatedField
from django.forms import model_to_dict
from rest_framework.authentication import BaseAuthentication

from rest_framework.exceptions import AuthenticationFailed

logger = logging.getLogger(__name__)


class CustomAuthentication(BaseAuthentication):

    def authenticate(self, request):
        logger.debug('authenticate')
        token = request._request.GET.get('token')
        if not token:
            raise AuthenticationFailed('AuthenticationFailed')
        return "chench", None

    def authenticate_header(self, request):
        super().authenticate_header(request)
